
const HtmlWebpackPlugin = require('html-webpack-plugin')

const { resolve } = require('path')
const htmlPublicPath = resolve(__dirname, 'build')
function RooPath(path) {
  return resolve(__dirname, path)
}

module.exports = {
  // 单入口 - 就一个 bundle
  // entry: RooPath('./src/js/index.js'),
  entry: {
    // 多入口 ****
    main: RooPath('./src/js/index.js'),
    test: RooPath('./src/js/test.js')
  },
  output: {
    // [name]: 取文件名
    filename: 'js/[name].[contenthash:10].js',
    path: htmlPublicPath,
    publicPath: './',
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: RooPath('./src/index.html')
    }),
  ],
  mode: 'production', // 生成模式
}